<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.5"/>
<title>xilsecure: XilSecure AES ZynqMP APIs</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="HTML_custom.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="xlogo_bg.png"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">xilsecure
   </div>
   <div id="projectbrief">Vitis Drivers API Documentation</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.5 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Overview</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li><a href="globals.html"><span>APIs</span></a></li>
      <li><a href="files.html"><span>File&#160;List</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;"
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('group__xsecure__aes__zynqmp__apis.html','');});
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#define-members">Macros</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">XilSecure AES ZynqMP APIs</div>  </div>
</div><!--header-->
<div class="contents">
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a>
Macros</h2></td></tr>
<tr class="memitem:ga99f31d64c5559493db205be3c6bb4d69"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__xsecure__aes__zynqmp__apis.html#ga99f31d64c5559493db205be3c6bb4d69">XSecure_AesWaitForDone</a>(InstancePtr)</td></tr>
<tr class="memdesc:ga99f31d64c5559493db205be3c6bb4d69"><td class="mdescLeft">&#160;</td><td class="mdescRight">This macro waits for AES engine completes configured operation.  <a href="#ga99f31d64c5559493db205be3c6bb4d69">More...</a><br/></td></tr>
<tr class="separator:ga99f31d64c5559493db205be3c6bb4d69"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:gadeb15e6ff58fe7e52935350e1a92a102"><td class="memItemLeft" align="right" valign="top">s32&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__xsecure__aes__zynqmp__apis.html#gadeb15e6ff58fe7e52935350e1a92a102">XSecure_AesInitialize</a> (XSecure_Aes *InstancePtr, XCsuDma *CsuDmaPtr, u32 KeySel, u32 *IvPtr, u32 *KeyPtr)</td></tr>
<tr class="memdesc:gadeb15e6ff58fe7e52935350e1a92a102"><td class="mdescLeft">&#160;</td><td class="mdescRight">This function initializes the instance pointer.  <a href="#gadeb15e6ff58fe7e52935350e1a92a102">More...</a><br/></td></tr>
<tr class="separator:gadeb15e6ff58fe7e52935350e1a92a102"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga78edf33e47f7a19be135b194af962d2c"><td class="memItemLeft" align="right" valign="top">u32&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__xsecure__aes__zynqmp__apis.html#ga78edf33e47f7a19be135b194af962d2c">XSecure_AesDecryptInit</a> (XSecure_Aes *InstancePtr, u8 *DecData, u32 Size, u8 *GcmTagAddr)</td></tr>
<tr class="memdesc:ga78edf33e47f7a19be135b194af962d2c"><td class="mdescLeft">&#160;</td><td class="mdescRight">This function initializes the AES engine for decryption and is required to be called before calling XSecure_AesDecryptUpdate.  <a href="#ga78edf33e47f7a19be135b194af962d2c">More...</a><br/></td></tr>
<tr class="separator:ga78edf33e47f7a19be135b194af962d2c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga4db7441166b2271ceaac1ac859a15c60"><td class="memItemLeft" align="right" valign="top">s32&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__xsecure__aes__zynqmp__apis.html#ga4db7441166b2271ceaac1ac859a15c60">XSecure_AesDecryptUpdate</a> (XSecure_Aes *InstancePtr, u8 *EncData, u32 Size)</td></tr>
<tr class="memdesc:ga4db7441166b2271ceaac1ac859a15c60"><td class="mdescLeft">&#160;</td><td class="mdescRight">This function decrypts the encrypted data passed in and updates the GCM tag from any previous calls.  <a href="#ga4db7441166b2271ceaac1ac859a15c60">More...</a><br/></td></tr>
<tr class="separator:ga4db7441166b2271ceaac1ac859a15c60"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gabaf0da2dbbd5f793378a8cc3700a8ef7"><td class="memItemLeft" align="right" valign="top">s32&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__xsecure__aes__zynqmp__apis.html#gabaf0da2dbbd5f793378a8cc3700a8ef7">XSecure_AesDecryptData</a> (XSecure_Aes *InstancePtr, u8 *DecData, u8 *EncData, u32 Size, u8 *GcmTagAddr)</td></tr>
<tr class="memdesc:gabaf0da2dbbd5f793378a8cc3700a8ef7"><td class="mdescLeft">&#160;</td><td class="mdescRight">This function decrypts the encrypted data provided and updates the DecData buffer with decrypted data.  <a href="#gabaf0da2dbbd5f793378a8cc3700a8ef7">More...</a><br/></td></tr>
<tr class="separator:gabaf0da2dbbd5f793378a8cc3700a8ef7"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga9d60cf825dcf6e7eb30d734f01014266"><td class="memItemLeft" align="right" valign="top">s32&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__xsecure__aes__zynqmp__apis.html#ga9d60cf825dcf6e7eb30d734f01014266">XSecure_AesDecrypt</a> (XSecure_Aes *InstancePtr, u8 *Dst, const u8 *Src, u32 Length)</td></tr>
<tr class="memdesc:ga9d60cf825dcf6e7eb30d734f01014266"><td class="mdescLeft">&#160;</td><td class="mdescRight">This function will handle the AES-GCM Decryption.  <a href="#ga9d60cf825dcf6e7eb30d734f01014266">More...</a><br/></td></tr>
<tr class="separator:ga9d60cf825dcf6e7eb30d734f01014266"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga7b2c563fa3324f4f329b775f314b96c4"><td class="memItemLeft" align="right" valign="top">u32&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__xsecure__aes__zynqmp__apis.html#ga7b2c563fa3324f4f329b775f314b96c4">XSecure_AesEncryptInit</a> (XSecure_Aes *InstancePtr, u8 *EncData, u32 Size)</td></tr>
<tr class="memdesc:ga7b2c563fa3324f4f329b775f314b96c4"><td class="mdescLeft">&#160;</td><td class="mdescRight">This function is used to initialize the AES engine for encryption.  <a href="#ga7b2c563fa3324f4f329b775f314b96c4">More...</a><br/></td></tr>
<tr class="separator:ga7b2c563fa3324f4f329b775f314b96c4"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gabdefc1128b9769010e42070e15f06d74"><td class="memItemLeft" align="right" valign="top">u32&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__xsecure__aes__zynqmp__apis.html#gabdefc1128b9769010e42070e15f06d74">XSecure_AesEncryptUpdate</a> (XSecure_Aes *InstancePtr, const u8 *Data, u32 Size)</td></tr>
<tr class="memdesc:gabdefc1128b9769010e42070e15f06d74"><td class="mdescLeft">&#160;</td><td class="mdescRight">This function encrypts the clear-text data passed in and updates the GCM tag from any previous calls.  <a href="#gabdefc1128b9769010e42070e15f06d74">More...</a><br/></td></tr>
<tr class="separator:gabdefc1128b9769010e42070e15f06d74"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gace1d0dd6146035c42a6ae0add6f0d09a"><td class="memItemLeft" align="right" valign="top">u32&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__xsecure__aes__zynqmp__apis.html#gace1d0dd6146035c42a6ae0add6f0d09a">XSecure_AesEncryptData</a> (XSecure_Aes *InstancePtr, u8 *Dst, const u8 *Src, u32 Len)</td></tr>
<tr class="memdesc:gace1d0dd6146035c42a6ae0add6f0d09a"><td class="mdescLeft">&#160;</td><td class="mdescRight">This function encrypts Len (length) number of bytes of the passed in Src (source) buffer and stores the encrypted data along with its associated 16 byte tag in the Dst (destination) buffer.  <a href="#gace1d0dd6146035c42a6ae0add6f0d09a">More...</a><br/></td></tr>
<tr class="separator:gace1d0dd6146035c42a6ae0add6f0d09a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga88b6213e7e2f971ea5de22040b4f2510"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__xsecure__aes__zynqmp__apis.html#ga88b6213e7e2f971ea5de22040b4f2510">XSecure_AesReset</a> (XSecure_Aes *InstancePtr)</td></tr>
<tr class="memdesc:ga88b6213e7e2f971ea5de22040b4f2510"><td class="mdescLeft">&#160;</td><td class="mdescRight">This function sets and then clears the AES-GCM's reset line.  <a href="#ga88b6213e7e2f971ea5de22040b4f2510">More...</a><br/></td></tr>
<tr class="separator:ga88b6213e7e2f971ea5de22040b4f2510"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Macro Definition Documentation</h2>
<a class="anchor" id="ga99f31d64c5559493db205be3c6bb4d69"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define XSecure_AesWaitForDone</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">InstancePtr</td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<b>Value:</b><div class="fragment"><div class="line">Xil_WaitForEvent((InstancePtr)-&gt;BaseAddress + <a class="code" href="xsecure__aes__hw_8h.html#ad630ee247405208df10c42bea596dafb">XSECURE_CSU_AES_STS_OFFSET</a>,\</div>
<div class="line">                        XSECURE_CSU_AES_STS_AES_BUSY,   \</div>
<div class="line">                        0U,     \</div>
<div class="line">                        XSECURE_AES_TIMEOUT_MAX)</div>
<div class="ttc" id="xsecure__aes__hw_8h_html_ad630ee247405208df10c42bea596dafb"><div class="ttname"><a href="xsecure__aes__hw_8h.html#ad630ee247405208df10c42bea596dafb">XSECURE_CSU_AES_STS_OFFSET</a></div><div class="ttdeci">#define XSECURE_CSU_AES_STS_OFFSET</div><div class="ttdoc">AES Status. </div><div class="ttdef"><b>Definition:</b> xsecure_aes_hw.h:52</div></div>
</div><!-- fragment -->
<p>This macro waits for AES engine completes configured operation. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">InstancePtr</td><td>Pointer to the XSecure_Aes instance.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>XST_SUCCESS if the AES engine completes configured operation. XST_FAILURE if a timeout has occurred. </dd></dl>

<p>Referenced by <a class="el" href="group__xsecure__aes__zynqmp__apis.html#ga4db7441166b2271ceaac1ac859a15c60">XSecure_AesDecryptUpdate()</a>, and <a class="el" href="group__xsecure__aes__zynqmp__apis.html#gabdefc1128b9769010e42070e15f06d74">XSecure_AesEncryptUpdate()</a>.</p>

</div>
</div>
<h2 class="groupheader">Function Documentation</h2>
<a class="anchor" id="ga9d60cf825dcf6e7eb30d734f01014266"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">s32 XSecure_AesDecrypt </td>
          <td>(</td>
          <td class="paramtype">XSecure_Aes *&#160;</td>
          <td class="paramname"><em>InstancePtr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u8 *&#160;</td>
          <td class="paramname"><em>Dst</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const u8 *&#160;</td>
          <td class="paramname"><em>Src</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u32&#160;</td>
          <td class="paramname"><em>Length</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This function will handle the AES-GCM Decryption. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">InstancePtr</td><td>Pointer to the XSecure_Aes instance. </td></tr>
    <tr><td class="paramname">Src</td><td>Pointer to encrypted data source location </td></tr>
    <tr><td class="paramname">Dst</td><td>Pointer to location where decrypted data will be written. </td></tr>
    <tr><td class="paramname">Length</td><td>Expected total length of decrypted image expected.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>returns XST_SUCCESS if successful, or the relevant errorcode.</dd></dl>
<dl class="section note"><dt>Note</dt><dd>This function is used for decrypting the Image's partition encrypted by Bootgen </dd></dl>

<p>References <a class="el" href="group__xsecure__aes__client__apis.html#gaa3c4b19232e0c5fa8cf14d69410e31e7">XSecure_AesKeyZero()</a>, <a class="el" href="group__xsecure__aes__zynqmp__apis.html#ga88b6213e7e2f971ea5de22040b4f2510">XSecure_AesReset()</a>, <a class="el" href="xsecure__aes__hw_8h.html#a65de8895ca639c0793d5f3bc3b7ff127">XSECURE_CSU_AES_CFG_OFFSET</a>, <a class="el" href="xsecure__aes__hw_8h.html#a288b9458ee0a6ca2541a80df9bbdf2b5">XSECURE_CSU_AES_IV_0_OFFSET</a>, <a class="el" href="xsecure__aes__hw_8h.html#aec24a13d03bd602adc1f46eee16fcaf8">XSECURE_CSU_AES_IV_3_OFFSET</a>, <a class="el" href="xsecure__aes__hw_8h.html#aefe6749b6b1e100f76c8b489f5143452">XSECURE_CSU_AES_KEY_CLR_OFFSET</a>, <a class="el" href="xsecure__aes__hw_8h.html#aadc62cc398f22228ef7972c28b1bc2b4">XSECURE_CSU_AES_KUP_0_OFFSET</a>, <a class="el" href="xsecure__aes__hw_8h.html#aac3ef8dc2d3278648d10fcccab4c4267">XSECURE_CSU_AES_RESET_OFFSET</a>, <a class="el" href="group__xsecure__generic__server__apis.html#gae500e79a22c37a14027ce0ad88a8cafe">XSecure_Out32</a>, <a class="el" href="group__xsecure__generic__server__apis.html#ga7d9385d1d7121998a9be90e90d3a8f7b">XSecure_SetReset()</a>, and <a class="el" href="group__xsecure__helper__server__apis.html#ggab4e2a6423dfb2e446d7dc1ee602c6ea5ad99985ebb6cf4318c4ff571557bc6b09">XSECURE_SSS_DMA0</a>.</p>

<p>Referenced by <a class="el" href="group__xsecure__apis.html#ga2b8b3f8c925d15be80cff15f248c1532">SecureAesExample()</a>.</p>

</div>
</div>
<a class="anchor" id="gabaf0da2dbbd5f793378a8cc3700a8ef7"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">s32 XSecure_AesDecryptData </td>
          <td>(</td>
          <td class="paramtype">XSecure_Aes *&#160;</td>
          <td class="paramname"><em>InstancePtr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u8 *&#160;</td>
          <td class="paramname"><em>DecData</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u8 *&#160;</td>
          <td class="paramname"><em>EncData</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u32&#160;</td>
          <td class="paramname"><em>Size</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u8 *&#160;</td>
          <td class="paramname"><em>GcmTagAddr</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This function decrypts the encrypted data provided and updates the DecData buffer with decrypted data. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">InstancePtr</td><td>Pointer to the XSecure_Aes instance. </td></tr>
    <tr><td class="paramname">DecData</td><td>Pointer to a buffer in which decrypted data will be stored. </td></tr>
    <tr><td class="paramname">EncData</td><td>Pointer to the encrypted data which needs to be decrypted. </td></tr>
    <tr><td class="paramname">Size</td><td>Size of data to be decrypted in bytes, whereas the number of bytes should be multiples of 4. </td></tr>
    <tr><td class="paramname">Size</td><td>Size of data to be decrypted in bytes, whereas the number of bytes should be multiples of 4. </td></tr>
    <tr><td class="paramname">GcmTagAddr</td><td>Pointer to a buffer in which GCM tag address will be stored. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>This API returns the status of GCM tag matching.<ul>
<li>XSECURE_CSU_AES_GCM_TAG_MISMATCH: If GCM tag was mismatched</li>
<li>XST_SUCCESS: If GCM tag was matched.</li>
</ul>
</dd></dl>
<dl class="section note"><dt>Note</dt><dd>When using this function to decrypt data that was encrypted with XSecure_AesEncryptData, the GCM tag will be stored as the last sixteen (16) bytes of data in XSecure_AesEncryptData's Dst (destination) buffer and should be used as the GcmTagAddr's pointer. </dd></dl>

<p>References <a class="el" href="group__xsecure__aes__client__apis.html#gacea2fc49243f66d0b440a95d1bd6170f">XSecure_AesDecryptInit()</a>, and <a class="el" href="group__xsecure__aes__client__apis.html#ga3150fb8656509ac0217c44c9609776cc">XSecure_AesDecryptUpdate()</a>.</p>

</div>
</div>
<a class="anchor" id="ga78edf33e47f7a19be135b194af962d2c"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">u32 XSecure_AesDecryptInit </td>
          <td>(</td>
          <td class="paramtype">XSecure_Aes *&#160;</td>
          <td class="paramname"><em>InstancePtr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u8 *&#160;</td>
          <td class="paramname"><em>DecData</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u32&#160;</td>
          <td class="paramname"><em>Size</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u8 *&#160;</td>
          <td class="paramname"><em>GcmTagAddr</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This function initializes the AES engine for decryption and is required to be called before calling XSecure_AesDecryptUpdate. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">InstancePtr</td><td>Pointer to the XSecure_Aes instance. </td></tr>
    <tr><td class="paramname">DecData</td><td>Pointer in which decrypted data will be stored. </td></tr>
    <tr><td class="paramname">Size</td><td>Expected size of the data in bytes whereas the number of bytes provided should be multiples of 4.</td></tr>
    <tr><td class="paramname">GcmTagAddr</td><td>Pointer to the GCM tag which needs to be verified during decryption of the data.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>None</dd></dl>
<dl class="section note"><dt>Note</dt><dd>If all of the data to be decrypted is available, the XSecure_AesDecryptData function can be used instead. </dd></dl>

<p>References <a class="el" href="group__xsecure__aes__client__apis.html#gaa3c4b19232e0c5fa8cf14d69410e31e7">XSecure_AesKeyZero()</a>, <a class="el" href="group__xsecure__aes__zynqmp__apis.html#ga88b6213e7e2f971ea5de22040b4f2510">XSecure_AesReset()</a>, <a class="el" href="xsecure__aes__hw_8h.html#a65de8895ca639c0793d5f3bc3b7ff127">XSECURE_CSU_AES_CFG_OFFSET</a>, <a class="el" href="xsecure__aes__hw_8h.html#aefe6749b6b1e100f76c8b489f5143452">XSECURE_CSU_AES_KEY_CLR_OFFSET</a>, <a class="el" href="xsecure__aes__hw_8h.html#aadc62cc398f22228ef7972c28b1bc2b4">XSECURE_CSU_AES_KUP_0_OFFSET</a>, <a class="el" href="xsecure__aes__hw_8h.html#aac3ef8dc2d3278648d10fcccab4c4267">XSECURE_CSU_AES_RESET_OFFSET</a>, <a class="el" href="xsecure__aes__hw_8h.html#a5fc757392b9473d3902cb3c214639e32">XSECURE_CSU_AES_START_MSG_OFFSET</a>, <a class="el" href="group__xsecure__generic__server__apis.html#gae500e79a22c37a14027ce0ad88a8cafe">XSecure_Out32</a>, <a class="el" href="group__xsecure__generic__server__apis.html#ga7d9385d1d7121998a9be90e90d3a8f7b">XSecure_SetReset()</a>, and <a class="el" href="group__xsecure__helper__server__apis.html#ggab4e2a6423dfb2e446d7dc1ee602c6ea5ad99985ebb6cf4318c4ff571557bc6b09">XSECURE_SSS_DMA0</a>.</p>

</div>
</div>
<a class="anchor" id="ga4db7441166b2271ceaac1ac859a15c60"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">s32 XSecure_AesDecryptUpdate </td>
          <td>(</td>
          <td class="paramtype">XSecure_Aes *&#160;</td>
          <td class="paramname"><em>InstancePtr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u8 *&#160;</td>
          <td class="paramname"><em>EncData</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u32&#160;</td>
          <td class="paramname"><em>Size</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This function decrypts the encrypted data passed in and updates the GCM tag from any previous calls. </p>
<p>The size from XSecure_AesDecryptInit is decremented from the size passed into this function to determine when the GCM tag passed to XSecure_AesDecryptInit needs to be compared to the GCM tag calculated in the AES engine.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">InstancePtr</td><td>Pointer to the XSecure_Aes instance. </td></tr>
    <tr><td class="paramname">EncData</td><td>Pointer to the encrypted data which needs to be decrypted. </td></tr>
    <tr><td class="paramname">Size</td><td>Expected size of data to be decrypted in bytes, whereas the number of bytes should be multiples of 4.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Final call of this API returns the status of GCM tag matching.<ul>
<li>XSECURE_CSU_AES_GCM_TAG_MISMATCH: If GCM tag is mismatched</li>
<li>XSECURE_CSU_AES_ZEROIZATION_ERROR: If GCM tag is mismatched, zeroize the decrypted data and send the status of zeroization.</li>
<li>XST_SUCCESS: If GCM tag is matching.</li>
</ul>
</dd></dl>
<dl class="section note"><dt>Note</dt><dd>When Size of the data equals to size of the remaining data that data will be treated as final data. This API can be called multpile times but sum of all Sizes should be equal to Size mention in init. Return of the final call of this API tells whether GCM tag is matching or not. </dd></dl>

<p>References <a class="el" href="group__xsecure__aes__client__apis.html#gaa3c4b19232e0c5fa8cf14d69410e31e7">XSecure_AesKeyZero()</a>, <a class="el" href="group__xsecure__aes__zynqmp__apis.html#ga99f31d64c5559493db205be3c6bb4d69">XSecure_AesWaitForDone</a>, <a class="el" href="xsecure__aes__hw_8h.html#aec24a13d03bd602adc1f46eee16fcaf8">XSECURE_CSU_AES_IV_3_OFFSET</a>, <a class="el" href="xsecure__aes__hw_8h.html#aac3ef8dc2d3278648d10fcccab4c4267">XSECURE_CSU_AES_RESET_OFFSET</a>, <a class="el" href="xsecure__aes__hw_8h.html#ad630ee247405208df10c42bea596dafb">XSECURE_CSU_AES_STS_OFFSET</a>, and <a class="el" href="group__xsecure__generic__server__apis.html#ga7d9385d1d7121998a9be90e90d3a8f7b">XSecure_SetReset()</a>.</p>

</div>
</div>
<a class="anchor" id="gace1d0dd6146035c42a6ae0add6f0d09a"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">u32 XSecure_AesEncryptData </td>
          <td>(</td>
          <td class="paramtype">XSecure_Aes *&#160;</td>
          <td class="paramname"><em>InstancePtr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u8 *&#160;</td>
          <td class="paramname"><em>Dst</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const u8 *&#160;</td>
          <td class="paramname"><em>Src</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u32&#160;</td>
          <td class="paramname"><em>Len</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This function encrypts Len (length) number of bytes of the passed in Src (source) buffer and stores the encrypted data along with its associated 16 byte tag in the Dst (destination) buffer. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">InstancePtr</td><td>A pointer to the XSecure_Aes instance. </td></tr>
    <tr><td class="paramname">Dst</td><td>A pointer to a buffer where encrypted data along with GCM tag will be stored. The Size of buffer provided should be Size of the data plus 16 bytes </td></tr>
    <tr><td class="paramname">Src</td><td>A pointer to input data for encryption. </td></tr>
    <tr><td class="paramname">Len</td><td>Size of input data in bytes, whereas the number of bytes provided should be multiples of 4.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>None</dd></dl>
<dl class="section note"><dt>Note</dt><dd>If data to be encrypted is not available in one buffer one can call <a class="el" href="group__xsecure__aes__client__apis.html#ga23f9b2bfaf978518d82c19d8331c9cb8" title="This function sends IPI request to EncryptInit the AES engine. ">XSecure_AesEncryptInit()</a> and update the AES engine with data to be encrypted by calling <a class="el" href="group__xsecure__aes__client__apis.html#ga162a8009f9d4983d841b517fe53d14c4" title="This function sends IPI request to update the input data to AES engine for encryption. ">XSecure_AesEncryptUpdate()</a> API multiple times as required. </dd></dl>

<p>References <a class="el" href="group__xsecure__aes__client__apis.html#ga23f9b2bfaf978518d82c19d8331c9cb8">XSecure_AesEncryptInit()</a>, and <a class="el" href="group__xsecure__aes__client__apis.html#ga162a8009f9d4983d841b517fe53d14c4">XSecure_AesEncryptUpdate()</a>.</p>

</div>
</div>
<a class="anchor" id="ga7b2c563fa3324f4f329b775f314b96c4"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">u32 XSecure_AesEncryptInit </td>
          <td>(</td>
          <td class="paramtype">XSecure_Aes *&#160;</td>
          <td class="paramname"><em>InstancePtr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u8 *&#160;</td>
          <td class="paramname"><em>EncData</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u32&#160;</td>
          <td class="paramname"><em>Size</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This function is used to initialize the AES engine for encryption. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">InstancePtr</td><td>Pointer to the XSecure_Aes instance. </td></tr>
    <tr><td class="paramname">EncData</td><td>Pointer of a buffer in which encrypted data along with GCM TAG will be stored. Buffer size should be Size of data plus 16 bytes. </td></tr>
    <tr><td class="paramname">Size</td><td>A 32 bit variable, which holds the size of the input data to be encrypted in bytes, whereas number of bytes provided should be multiples of 4.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>None</dd></dl>
<dl class="section note"><dt>Note</dt><dd>If all of the data to be encrypted is available, the XSecure_AesEncryptData function can be used instead. </dd></dl>

<p>References <a class="el" href="group__xsecure__aes__client__apis.html#gaa3c4b19232e0c5fa8cf14d69410e31e7">XSecure_AesKeyZero()</a>, <a class="el" href="group__xsecure__aes__zynqmp__apis.html#ga88b6213e7e2f971ea5de22040b4f2510">XSecure_AesReset()</a>, <a class="el" href="xsecure__aes__hw_8h.html#a65de8895ca639c0793d5f3bc3b7ff127">XSECURE_CSU_AES_CFG_OFFSET</a>, <a class="el" href="xsecure__aes__hw_8h.html#aefe6749b6b1e100f76c8b489f5143452">XSECURE_CSU_AES_KEY_CLR_OFFSET</a>, <a class="el" href="xsecure__aes__hw_8h.html#aadc62cc398f22228ef7972c28b1bc2b4">XSECURE_CSU_AES_KUP_0_OFFSET</a>, <a class="el" href="xsecure__aes__hw_8h.html#aac3ef8dc2d3278648d10fcccab4c4267">XSECURE_CSU_AES_RESET_OFFSET</a>, <a class="el" href="xsecure__aes__hw_8h.html#a5fc757392b9473d3902cb3c214639e32">XSECURE_CSU_AES_START_MSG_OFFSET</a>, <a class="el" href="group__xsecure__generic__server__apis.html#gae500e79a22c37a14027ce0ad88a8cafe">XSecure_Out32</a>, <a class="el" href="group__xsecure__generic__server__apis.html#ga7d9385d1d7121998a9be90e90d3a8f7b">XSecure_SetReset()</a>, and <a class="el" href="group__xsecure__helper__server__apis.html#ggab4e2a6423dfb2e446d7dc1ee602c6ea5ad99985ebb6cf4318c4ff571557bc6b09">XSECURE_SSS_DMA0</a>.</p>

</div>
</div>
<a class="anchor" id="gabdefc1128b9769010e42070e15f06d74"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">u32 XSecure_AesEncryptUpdate </td>
          <td>(</td>
          <td class="paramtype">XSecure_Aes *&#160;</td>
          <td class="paramname"><em>InstancePtr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const u8 *&#160;</td>
          <td class="paramname"><em>Data</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u32&#160;</td>
          <td class="paramname"><em>Size</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This function encrypts the clear-text data passed in and updates the GCM tag from any previous calls. </p>
<p>The size from XSecure_AesEncryptInit is decremented from the size passed into this function to determine when the final CSU DMA transfer of data to the AES-GCM cryptographic core.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">InstancePtr</td><td>Pointer to the XSecure_Aes instance. </td></tr>
    <tr><td class="paramname">Data</td><td>Pointer to the data for which encryption should be performed. </td></tr>
    <tr><td class="paramname">Size</td><td>A 32 bit variable, which holds the size of the input data in bytes, whereas the number of bytes provided should be multiples of 4.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>None</dd></dl>
<dl class="section note"><dt>Note</dt><dd>If all of the data to be encrypted is available, the XSecure_AesEncryptData function can be used instead. </dd></dl>

<p>References <a class="el" href="group__xsecure__aes__client__apis.html#gaa3c4b19232e0c5fa8cf14d69410e31e7">XSecure_AesKeyZero()</a>, <a class="el" href="group__xsecure__aes__zynqmp__apis.html#ga99f31d64c5559493db205be3c6bb4d69">XSecure_AesWaitForDone</a>, <a class="el" href="xsecure__aes__hw_8h.html#aac3ef8dc2d3278648d10fcccab4c4267">XSECURE_CSU_AES_RESET_OFFSET</a>, and <a class="el" href="group__xsecure__generic__server__apis.html#ga7d9385d1d7121998a9be90e90d3a8f7b">XSecure_SetReset()</a>.</p>

</div>
</div>
<a class="anchor" id="gadeb15e6ff58fe7e52935350e1a92a102"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">s32 XSecure_AesInitialize </td>
          <td>(</td>
          <td class="paramtype">XSecure_Aes *&#160;</td>
          <td class="paramname"><em>InstancePtr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">XCsuDma *&#160;</td>
          <td class="paramname"><em>CsuDmaPtr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u32&#160;</td>
          <td class="paramname"><em>KeySel</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u32 *&#160;</td>
          <td class="paramname"><em>IvPtr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u32 *&#160;</td>
          <td class="paramname"><em>KeyPtr</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This function initializes the instance pointer. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">InstancePtr</td><td>Pointer to the XSecure_Aes instance. </td></tr>
    <tr><td class="paramname">CsuDmaPtr</td><td>Pointer to the XCsuDma instance. </td></tr>
    <tr><td class="paramname">KeySel</td><td>Key source for decryption, can be KUP/device key<ul>
<li>XSECURE_CSU_AES_KEY_SRC_KUP :For KUP key</li>
<li>XSECURE_CSU_AES_KEY_SRC_DEV :For Device Key </li>
</ul>
</td></tr>
    <tr><td class="paramname">IvPtr</td><td>Pointer to the Initialization Vector for decryption </td></tr>
    <tr><td class="paramname">KeyPtr</td><td>Pointer to Aes key in case KUP key is used. Pass <code>Null</code> if the device key is to be used.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>XST_SUCCESS if initialization was successful.</dd></dl>
<dl class="section note"><dt>Note</dt><dd>All the inputs are accepted in little endian format but the AES engine accepts the data in big endian format, The decryption and encryption functions in xsecure_aes handle the little endian to big endian conversion using few API's, Xil_Htonl (provided by Xilinx xil_io library) and XSecure_AesCsuDmaConfigureEndiannes for handling data endianness conversions. If higher performance is needed, users can strictly use data in big endian format and modify the xsecure_aes functions to remove the use of the Xil_Htonl and XSecure_AesCsuDmaConfigureEndiannes functions as required. </dd></dl>

<p>References <a class="el" href="group__xsecure__generic__server__apis.html#ga162af494e626229733557c1c87fb2e15">XSecure_CryptoCheck()</a>, and <a class="el" href="xsecure__aes__hw_8h.html#aae1144b9830a93d8a345636a8082431c">XSECURE_CSU_AES_BASE</a>.</p>

</div>
</div>
<a class="anchor" id="ga88b6213e7e2f971ea5de22040b4f2510"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void XSecure_AesReset </td>
          <td>(</td>
          <td class="paramtype">XSecure_Aes *&#160;</td>
          <td class="paramname"><em>InstancePtr</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This function sets and then clears the AES-GCM's reset line. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">InstancePtr</td><td>is a pointer to the XSecure_Aes instance.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>None </dd></dl>

<p>References <a class="el" href="xsecure__aes__hw_8h.html#aac3ef8dc2d3278648d10fcccab4c4267">XSECURE_CSU_AES_RESET_OFFSET</a>, and <a class="el" href="group__xsecure__generic__server__apis.html#ga448da91f94630d83a52c21b895455ebf">XSecure_ReleaseReset()</a>.</p>

<p>Referenced by <a class="el" href="group__xsecure__aes__zynqmp__apis.html#ga9d60cf825dcf6e7eb30d734f01014266">XSecure_AesDecrypt()</a>, <a class="el" href="group__xsecure__aes__zynqmp__apis.html#ga78edf33e47f7a19be135b194af962d2c">XSecure_AesDecryptInit()</a>, and <a class="el" href="group__xsecure__aes__zynqmp__apis.html#ga7b2c563fa3324f4f329b775f314b96c4">XSecure_AesEncryptInit()</a>.</p>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
	<p class="footer">&copy; Copyright 2015-2022 Xilinx, Inc. All Rights Reserved.</p>
	<p class="footer">&copy; Copyright 2022-2023 Advanced Micro Devices, Inc. All Rights Reserved.</p>
</div>
</body>
</html>
